package com.edar.web.struts2.component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.UIBean;
import org.apache.struts2.views.annotations.StrutsTag;

import com.opensymphony.xwork2.util.ValueStack;
@StrutsTag(name="page", tldTagClass="com.edar.web.struts2.tag.PageTag", description="定义一个公共的分页组件，提供页面web显示.")
public class Page extends UIBean {
	/**
	 * PageTag的默认模板名称
	 */
	 final public static String TEMPLATE = "page";

	private String headTitle;
	private String baseNav;
	private String numberNav;
	private String selectPageSize;
	private String input;
    private String url;   //action的路径
    public Page(ValueStack stack, HttpServletRequest request,HttpServletResponse response) {
		super(stack, request, response);
	}
	
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

	public String getHeadTitle() {
		return headTitle;
	}
	public void setHeadTitle(String headTitle) {
		this.headTitle = headTitle;
	}
	public String getBaseNav() {
		return baseNav;
	}
	public void setBaseNav(String baseNav) {
		this.baseNav = baseNav;
	}
	public String getNumberNav() {
		return numberNav;
	}
	public void setNumberNav(String numberNav) {
		this.numberNav = numberNav;
	}
	public String getSelectPageSize() {
		return selectPageSize;
	}
	public void setSelectPageSize(String selectPageSize) {
		this.selectPageSize = selectPageSize;
	}
	public String getInput() {
		return input;
	}
	public void setInput(String input) {
		this.input = input;
	}
	@Override
	protected String getDefaultTemplate() {
		return TEMPLATE;
	}
	protected void evaluateExtraParams() {
        super.evaluateExtraParams();
        if (headTitle != null) {
            addParameter("headTitle", findValue(headTitle, Boolean.class));
        }
        if (baseNav != null) {
            addParameter("baseNav", findValue(baseNav, Boolean.class));
        }
        if (numberNav != null) {
            addParameter("numberNav", findValue(numberNav, Boolean.class));
        }
        if (selectPageSize != null) {
            addParameter("selectPageSize", findValue(selectPageSize, Boolean.class));
        }
        if (input != null) {
            addParameter("input", findValue(input, Boolean.class));
        }
	}
	
}
